class MainCursor extends egret.DisplayObjectContainer {
	Main: egret.DisplayObject;

	constructor(Main: egret.DisplayObject) {
		super();
		this.Main = Main;
		this.touchEnabled = false;
		this.touchChildren = false;
		// egret.sys.TouchHandler.
		window.document.addEventListener('mousemove', (e) => {
			this.onMouseMove(e);
		});
	}

	cursor: egret.DisplayObject;

	status: string;

	setCursor(status: string, img: egret.DisplayObject): void {
		safeRemoveFromFather(this.cursor);

		this.status = status;
		this.cursor = img;
		this.addChild(this.cursor); // 不断重复加自己的child，并没有问题
	}

	clearCursor(status: string): void {
		if (this.status === status) {
			safeRemoveFromFather(this.cursor);
			this.cursor = null;
		}
	}

	onMouseMove(ev: MouseEvent): void {
		// if (e.button == 2) //1 left  2 right 4 middle
		// console.log("onMouseMove 2",ev.button,ev.buttons)
		// if (ev.button & 2) {}
		const [x, y] = mouse2Game(ev.x, ev.y, this.Main);
		this.x = x;
		this.y = y;
		// getMapWindow().onMouseMove(x, y);
	}
}
